Public Class OccultBlood
    Protected _occult_blood_id As Integer
    Protected _occult_blood_name_tha As String
    Protected _occult_blood_name_eng As String
    Protected _Data As ArrayList
    Protected _DataCurrent As Integer

    Public Property occult_blood_id() As Integer
        Get
            Return _occult_blood_id
        End Get
        Set(ByVal value As Integer)
            _occult_blood_id = value
        End Set
    End Property

    Public Property occult_blood_name_tha() As String
        Get
            Return _occult_blood_name_tha
        End Get
        Set(ByVal value As String)
            _occult_blood_name_tha = value
        End Set
    End Property

    Public Property occult_blood_name_eng() As String
        Get
            Return _occult_blood_name_eng
        End Get
        Set(ByVal value As String)
            _occult_blood_name_eng = value
        End Set
    End Property

    Public Function getOccultBlood() As DataSet
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_OccultBlood"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "OccultBlood")

        Return objDs
    End Function

    Protected Function getsOccultBlood() As ArrayList
        Dim outResult As New ArrayList()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_OccultBlood"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "OccultBlood")

        For Each objDr As System.Data.DataRow In objDs.Tables("OccultBlood").Rows
            Dim obj As OccultBlood = New OccultBlood
            obj.occult_blood_id = objDr.Item("occult_blood_id").ToString()
            obj.occult_blood_name_tha = objDr.Item("occult_blood_name_tha").ToString()
            obj.occult_blood_name_eng = objDr.Item("occult_blood_name_eng").ToString()
            outResult.Add(obj)
        Next

        Return outResult
    End Function

    Public Function NextRecord() As Boolean
        If ((Not _Data Is Nothing) AndAlso (((Not _Data Is Nothing) AndAlso _
            (_DataCurrent < _Data.Count And _Data.Count > 0)))) Then
            _occult_blood_id = _Data(_DataCurrent).occult_blood_id
            _occult_blood_name_tha = _Data(_DataCurrent).occult_blood_name_tha
            _occult_blood_name_eng = _Data(_DataCurrent).occult_blood_name_eng
            _DataCurrent += 1
            Return True
        End If
        Return False
    End Function

    Public Sub LoadOccultBlood()
        _Data = New ArrayList
        _DataCurrent = 0
        _Data = getsOccultBlood()
    End Sub

    Public Function insertOccultBlood(ByVal inOccultBlood As OccultBlood) As Boolean
        Try
            Dim decryptText As New DateUtilities.Encrypt_Data()
            Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
                decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
                "PoliceHealthConnectionString").ToString(), True))
            Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "proc_INSERT_OccultBlood"

            Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodID", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_id))
            objCmd.Parameters.Add(objParam)

            objParam = New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodNameTha", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_name_tha))
            objCmd.Parameters.Add(objParam)

            objParam = New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodNameEng", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_name_eng))
            objCmd.Parameters.Add(objParam)

            objConn.Open()
            objCmd.ExecuteNonQuery()
            objConn.Close()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function updateOccultBlood(ByVal inOccultBlood As OccultBlood) As Boolean
        Try
            Dim decryptText As New DateUtilities.Encrypt_Data()
            Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
                decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
                "PoliceHealthConnectionString").ToString(), True))
            Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "proc_UPDATE_OccultBlood"

            Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodID", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_id))
            objCmd.Parameters.Add(objParam)

            objParam = New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodNameTha", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_name_tha))
            objCmd.Parameters.Add(objParam)

            objParam = New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodNameEng", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_name_eng))
            objCmd.Parameters.Add(objParam)

            objConn.Open()
            objCmd.ExecuteNonQuery()
            objConn.Close()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function deleteOccultBlood(ByVal inOccultBlood As OccultBlood) As Boolean
        Try
            Dim decryptText As New DateUtilities.Encrypt_Data()
            Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
                decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
                "PoliceHealthConnectionString").ToString(), True))
            Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "proc_DELETE_OccultBlood"

            Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodID", _
                Utilities.SendToDatabase(inOccultBlood.occult_blood_id))
            objCmd.Parameters.Add(objParam)

            objConn.Open()
            objCmd.ExecuteNonQuery()
            objConn.Close()

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Shared Function getOccultBloodByEngName(ByVal inOccultBloodEngName As String) As OccultBlood
        Dim outResult As New OccultBlood()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_OccultBloodByEngName"

        Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inOccultBloodEngName", inOccultBloodEngName)
        objCmd.Parameters.Add(objParam)

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "OccultBlood")

        For Each objDr As System.Data.DataRow In objDs.Tables("OccultBlood").Rows
            outResult.occult_blood_id = objDr.Item("occult_blood_id").ToString()
            outResult.occult_blood_name_tha = objDr.Item("occult_blood_name_tha").ToString()
            outResult.occult_blood_name_eng = objDr.Item("occult_blood_name_eng").ToString()
        Next

        Return outResult
    End Function

End Class
